<template>
  <div>
    <el-dialog
      :title="title"
      width= "400px"
      :visible.sync="dialogFormVisible"
      @closed="$emit('update:activated', false)"
    >
      <el-form class="search-form search-form-normal"  size="mini"   >
        <div   style="display: flex;height: 200px;flex-direction: column">
          <el-radio style="flex: 1;"  v-model="radio" label="1" >分票分箱报表</el-radio>
          <el-radio style="flex: 1" v-model="radio" label="2" >箱单发票报表</el-radio>
          <el-radio style="flex: 1" v-model="radio" label="3" >附件报表</el-radio>
          <el-radio style="flex: 1" v-model="radio" label="4" >保单样本报表</el-radio>
          <el-radio style="flex: 1" v-model="radio" label="5" >提单样本报表</el-radio>
          <el-radio style="flex: 1" v-model="radio" label="6" >铁路随车单据</el-radio>
        </div>
      </el-form>
      <span slot="footer">
          <el-button type="primary" size="mini" @click="submit">
            <i class="fa fa-check"></i> {{$t('searchFrom.confirm')}}</el-button>
          <el-button  size="mini" @click="cancel()">{{$t('searchFrom.cancel')}}</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import activityService from '@/api/warehouse/packingDetailsList'
  import {downloadBlobResponse} from '@/utils/request_utils'
  export default {
    name: "exportInfo",
    props:{
      data:{}
    },
    data(){
      return{
        dialogFormVisible  : true,
        radio:"1",
      }
    },
    computed:{
      title() {
        return this.$t('route.warehousePackingDetailsList') + this.$t('searchFrom.export')
      }
    },
    methods:{
      submit() {

        this.$confirm(this.$t("Tips.exportQueries"), this.$t("Tips.tips"), {
          confirmButtonText: this.$t("Tips.yes"),
          cancelButtonText: this.$t("Tips.no"),
          type: 'info',
          center: true
        }).then(() => {
          switch(this.radio) {
            case '1':
              if (this.data.billNo =="" || this.data.billNo == null ) {
                this.$notify({message: '导出信息时，输入的主提单号不能为空', type: "error"});
                return
              }
              return activityService.exportSubboxData({...this.data}).then(resp => {
                downloadBlobResponse(resp); // 文件下载
                this.dialogFormVisible = false
              });
            case '2':
              if ((this.data.caseNumber =="" || this.data.caseNumber == null) || (this.data.billNo =="" || this.data.billNo == null) ) {
                this.$notify({message: '导出信息时，输入的主提单号和箱号不能为空', type: "error"});
                return
              }
              return activityService.exportBoxInvoice({...this.data}).then(resp => {
                downloadBlobResponse(resp); // 文件下载
                this.dialogFormVisible = false
              });
            case '3':
              if (this.data.billNo =="" || this.data.billNo == null ) {
                this.$notify({message: '导出信息时，输入的主提单号不能为空', type: "error"});
                return
              }
              return activityService.exportAttadchmentData({...this.data}).then(resp => {
                downloadBlobResponse(resp); // 文件下载
                this.dialogFormVisible = false
              });
            case '4':
              if (this.data.billNo =="" || this.data.billNo == null ) {
                this.$notify({message: '导出信息时，输入的主提单号不能为空', type: "error"});
                return
              }
              return activityService.exportInsuranceReport({...this.data}).then(resp => {
                downloadBlobResponse(resp); // 文件下载
                this.dialogFormVisible = false
              });
            case '5':
              if (this.data.billNo =="" || this.data.billNo == null ) {
                this.$notify({message: '导出信息时，输入的主提单号不能为空', type: "error"});
                return
              }
              return activityService.exportBookingListData({...this.data}).then(resp => {
                downloadBlobResponse(resp); // 文件下载
                this.dialogFormVisible = false
              });
            case '6':
              if (this.data.caseNumber =="" || this.data.caseNumber == null ) {
                this.$notify({message: '导出信息时，输入的箱号不能为空', type: "error"});
                return
              }
              return activityService.billOfLadingSampleReport({...this.data}).then(resp => {
                downloadBlobResponse(resp); // 文件下载
                this.dialogFormVisible = false
              });
          }


          // debugger

        }).catch(() => {
          this.internal_activated = true;
        })//删除

      },
      /*取消*/
      cancel(){
        this.dialogFormVisible = false
      },
    }
  }
</script>

<style scoped>

</style>